<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>自定义设置界面</title>
    <script src="init.js?from=antd"></script>
    <style>
        #app {
            width: 800px;
            margin: auto;
        }
    </style>
</head>
<body>
<div id="app">
    <a-card title="自定义设置" style="width:100%;">
        <a-row style="text-align: center;">
            <a-col span="24">
                当前CDN为:{{now}}
            </a-col>
            <a-col span="12" style="margin-top:10px;">
                <a-button type="primary" @click="save('gitee')">
                    使用Gitee Pages
                </a-button>
            </a-col>
            <a-col span="12" style="margin-top:10px;">
                <a-button type="primary" @click="save('local')">
                    使用当前服务器
                </a-button>
            </a-col>
        </a-row>
    </a-card>
</div>
</body>
<script>
    Vue.app({
        data: {
            map: {
                gitee: "https://fs185085781.gitee.io/cdn",
                local: utils.rootPath + "/cdn"
            },
            now: ""
        },
        methods: {
            save: function (type) {
                var that = this;
                var url = that.map[type];
                utils.$.post("/php/action.php?type=0", {url: url}, function (res) {
                    utils.$.successMsg(res.msg);
                    that.initData();
                });
            },
            initData: function () {
                var that = this;
                utils.$.jsonp(utils.rootPath + "/cdn/cdn.js?_=" + new Date().getTime(),
                    function (cdn) {
                        that.now = cdn;
                    },
                    "initCdn");
            }
        },
        mounted: function () {
            this.initData();
        }
    });
</script>
</html>